
'''
Created on 2012-10-11

@author: admin
'''
import urllib2, re, datetime, time



def get_response_content(url):
    header = {'Accept-Charset':'GBK,utf-8;q=0.7,*;q=0.3', 'User-Agent' : 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.151 Safari/534.16'} 
    request = urllib2.Request(url, headers=header)
    repsonse_content = urllib2.urlopen(request,timeout=10*60).read()
    return repsonse_content

if __name__ == '__main__':
    i = 1
    tagscount = 0
    while 1:
        a = 60 * 60 * 1
        try:
            print datetime.datetime.now()
            print get_response_content('http://192.168.129.32/getnewnews/')
            i = 1
        except:
            print 'faile:news'
            a = 60 * 60 * i
            i = 1
            print a
        tagscount +=1
        if tagscount >24*7:
            try:
                print datetime.datetime.now()
                print get_response_content('http://192.168.129.32/addtags/')
                tagscount = 1
            except:
                print 'faile:tags'
        
        time.sleep(a)
